package com.design.命令模式;

import java.util.ArrayList;
import java.util.List;

public class Menu {

	private List<Command> commands;
	
	public Menu() {
		this.commands = new ArrayList<Command>();
	}
	
	public void writeMenu(Command command) {
		commands.add(command);
	}
	
	public void writeMenus(List<Command> scommands) {
		this.commands.addAll(scommands);
	}
	
	/**
	 * 执行
	 */
	public void execute() {
		if(commands != null && commands.size() > 0) {
			commands.forEach(command->{
				command.execute();
			});
		}
	}
}
